using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Data_Coordinate_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Data.Coordinate);
            args = new Type[]{};
            method = type.GetMethod("get_Size", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, get_Size_0);

            field = type.GetField("pos", flag);
            app.RegisterCLRFieldGetter(field, get_pos_0);
            app.RegisterCLRFieldSetter(field, set_pos_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_pos_0, AssignFromStack_pos_0);
            field = type.GetField("scale", flag);
            app.RegisterCLRFieldGetter(field, get_scale_1);
            app.RegisterCLRFieldSetter(field, set_scale_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_scale_1, AssignFromStack_scale_1);
            field = type.GetField("quat", flag);
            app.RegisterCLRFieldGetter(field, get_quat_2);
            app.RegisterCLRFieldSetter(field, set_quat_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_quat_2, AssignFromStack_quat_2);
            field = type.GetField("color", flag);
            app.RegisterCLRFieldGetter(field, get_color_3);
            app.RegisterCLRFieldSetter(field, set_color_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_color_3, AssignFromStack_color_3);

            app.RegisterCLRMemberwiseClone(type, PerformMemberwiseClone);

            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Data.Coordinate());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Data.Coordinate[s]);


        }

        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref huqiang.Data.Coordinate instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch(ptr_of_this_method->ObjectType)
            {
                case ObjectTypes.Object:
                    {
                        __mStack[ptr_of_this_method->Value] = instance_of_this_method;
                    }
                    break;
                case ObjectTypes.FieldReference:
                    {
                        var ___obj = __mStack[ptr_of_this_method->Value];
                        if(___obj is ILTypeInstance)
                        {
                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            var t = __domain.GetType(___obj.GetType()) as CLRType;
                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                        }
                    }
                    break;
                case ObjectTypes.StaticFieldReference:
                    {
                        var t = __domain.GetType(ptr_of_this_method->Value);
                        if(t is ILType)
                        {
                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                        }
                    }
                    break;
                 case ObjectTypes.ArrayReference:
                    {
                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as huqiang.Data.Coordinate[];
                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                    }
                    break;
            }
        }

        static StackObject* get_Size_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);


            var result_of_this_method = huqiang.Data.Coordinate.Size;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }


        static object get_pos_0(ref object o)
        {
            return ((huqiang.Data.Coordinate)o).pos;
        }

        static StackObject* CopyToStack_pos_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.Coordinate)o).pos;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_pos_0(ref object o, object v)
        {
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.pos = (UnityEngine.Vector3)v;
            o = ins;
        }

        static StackObject* AssignFromStack_pos_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Vector3 @pos = (UnityEngine.Vector3)typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)16);
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.pos = @pos;
            o = ins;
            return ptr_of_this_method;
        }

        static object get_scale_1(ref object o)
        {
            return ((huqiang.Data.Coordinate)o).scale;
        }

        static StackObject* CopyToStack_scale_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.Coordinate)o).scale;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_scale_1(ref object o, object v)
        {
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.scale = (UnityEngine.Vector3)v;
            o = ins;
        }

        static StackObject* AssignFromStack_scale_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Vector3 @scale = (UnityEngine.Vector3)typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)16);
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.scale = @scale;
            o = ins;
            return ptr_of_this_method;
        }

        static object get_quat_2(ref object o)
        {
            return ((huqiang.Data.Coordinate)o).quat;
        }

        static StackObject* CopyToStack_quat_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.Coordinate)o).quat;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_quat_2(ref object o, object v)
        {
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.quat = (UnityEngine.Quaternion)v;
            o = ins;
        }

        static StackObject* AssignFromStack_quat_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Quaternion @quat = (UnityEngine.Quaternion)typeof(UnityEngine.Quaternion).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)16);
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.quat = @quat;
            o = ins;
            return ptr_of_this_method;
        }

        static object get_color_3(ref object o)
        {
            return ((huqiang.Data.Coordinate)o).color;
        }

        static StackObject* CopyToStack_color_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.Coordinate)o).color;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_color_3(ref object o, object v)
        {
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.color = (UnityEngine.Color)v;
            o = ins;
        }

        static StackObject* AssignFromStack_color_3(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.Color @color = (UnityEngine.Color)typeof(UnityEngine.Color).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)16);
            huqiang.Data.Coordinate ins =(huqiang.Data.Coordinate)o;
            ins.color = @color;
            o = ins;
            return ptr_of_this_method;
        }


        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new huqiang.Data.Coordinate();
            ins = (huqiang.Data.Coordinate)o;
            return ins;
        }


    }
}
